<template>
  <div>
    <el-card class="box-card">
      <div slot="header" class="clearfix">
        <div>项目基本信息</div>
        <div>
          <el-button
            type="primary"
            icon="el-icon-edit"
            circle
            @click="dialogFormVisible = true"
          ></el-button>
          <el-button type="primary" icon="el-icon-refresh" circle></el-button>
        </div>
      </div>
      <el-row>
        <el-col :span="6">
          <div class="img">
            <span class="demonstration">项目图片</span>
            <div class="block">
              <el-image>
                <div slot="error" class="image-slot">
                  <i class="el-icon-picture-outline"></i>
                </div>
              </el-image>
            </div>
          </div>
        </el-col>
        <el-col :span="18">
          <div class="myflex">
            <div v-for="(value, key) in info" :key="key">
              <div class="label">{{ value.label }}</div>
              <div class="text">{{ value.value }}</div>
            </div>
          </div>
        </el-col>
      </el-row>
    </el-card>
    <el-card class="box-card">
      <div slot="header" class="clearfix">关联设备信息</div>
      <el-table :data="tableData" style="width: 100%">
        <el-table-column label="设备图片">
          <template slot-scope="scope">
            <el-image :src="scope.row.img">
              <div slot="error" class="image-slot">
                <i class="el-icon-picture-outline"></i>
              </div>
            </el-image>
          </template>
        </el-table-column>
        <el-table-column prop="id" label="设备ID"></el-table-column>
        <el-table-column prop="name" label="设备名称"></el-table-column>
        <el-table-column prop="model" label="设备型号"></el-table-column>
        <el-table-column prop="status" label="设备状态"></el-table-column>
        <el-table-column prop="adapter" label="适配器编号"></el-table-column>
        <el-table-column prop="time" label="设备创建时间"></el-table-column>
      </el-table>
    </el-card>

    <el-dialog title="编辑项目基本信息" :visible.sync="dialogFormVisible">
      <el-card class="box-card">
        <div slot="header" class="clearfix">
          <div>项目基本信息</div>
        </div>
        <el-row>
          <el-col :span="6">
            <div class="img">
              <span class="demonstration">项目图片</span>
              <div class="block">
                <el-image>
                  <div slot="error" class="image-slot">
                    <i class="el-icon-picture-outline"></i>
                  </div>
                </el-image>
              </div>
            </div>
          </el-col>
          <el-col :span="18">
            <div class="myflex2">
              <div
                v-for="(value, key) in info"
                :key="key"
                v-show="key != 'description'"
              >
                <div class="label">{{ value.label }}</div>
                <div class="text">{{ value.value }}</div>
              </div>
              <div>
                <div class="label">项目基本信息</div>
                <div>
                  <el-input
                    type="textarea"
                    :rows="2"
                    placeholder="请输入内容"
                    v-model="description_edit"
                  >
                  </el-input>
                </div>
              </div>
            </div>
          </el-col>
        </el-row>
      </el-card>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取 消</el-button>
        <el-button type="primary" @click="closeDialog">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  data() {
    return {
      dialogFormVisible: false,
      description_edit: "",
      info: {
        // img: '',
        code: {
          label: "项目编号",
          value: 1001,
        },
        name: {
          label: "客户名称",
          value: "气站--演示项目",
        },
        time: {
          label: "项目创建时间",
          value: "2018-11-04 10:59:47",
        },
        id: {
          label: "客户编号",
          value: 1012,
        },
        id_name: {
          label: "客户名称",
          value: "压缩机客户",
        },
        position: {
          label: "项目地理信息",
          value: "",
        },
        description: {
          label: "项目描述",
          value: "",
        },
      },
      tableData: [
        {
          img: "",
          id: 1009,
          name: "空压机-演示设备",
          model: "",
          status: "运行",
          adapter: ["A22017110300001"],
          time: "2018-11-03 10:28:23",
        },
      ],
    };
  },
  methods: {
    openDialog() {
      this.$data.description_edit = this.$data.info.description.value;
      this.$data.dialogFormVisible = true;
    },
    closeDialog() {
      this.$data.info.description.value = this.$data.description_edit;
      this.$data.dialogFormVisible = false;
    },
  },
};
</script>

<style scoped>
.block {
  display: flex;
  align-items: center;
  justify-content: center;
  /* width: 120px; */
  height: 100px;
  /* margin-bottom: 10px; */
  margin-right: 20px;
  background-color: #f3f3f3;
}

.image-slot {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
  background: #f5f7fa;
  color: #909399;
  font-size: 14px;
}
.myflex {
  padding-top: 10px;
  padding-bottom: 10px;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: flex-start;
  text-align: center;
  align-content: space-around;
  height: 150px;
}
.myflex2 {
  /* padding: 10px; */
  /* margin: 10px; */
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: flex-start;
  text-align: center;
  align-content: space-around;
  height: 200px;
}
.myflex > div {
  flex: 1 0 150px;
}
.myflex2 > div {
  flex: 1 0 150px;
}
.label {
  color: #909399;
}

.clearfix {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
}
</style>